import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus'
import zhLocale from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import * as Icons from '@element-plus/icons-vue'
import mitt from 'mitt'
import modal from '@/common/uilts/modal'
import { resetForm } from '@/common/uilts/CommonUtils'
import { download } from '@/common/uilts/request'
// 字典数据组件
import DictData from '@/components/DictData'
import { getDicts } from '@/components/DictData/data'
import { selectDictLabel, selectDictLabels } from '@/common/uilts/ruoyi'
import DictTag from '@/components/DictTag/index.vue'
// tailwindcss
import 'tailwindcss/tailwind.css'

export const app = createApp(App)
const bus = mitt()

// 注册所有图标
Object.keys(Icons).forEach(key => {
  app.component(key, Icons[key])
})

// 全局方法挂载
app.config.globalProperties.$bus = bus // 挂载事务总线
app.config.globalProperties.resetForm = resetForm
app.config.globalProperties.$modal = modal
app.config.globalProperties.download = download
app.config.globalProperties.getDicts = getDicts
app.config.globalProperties.selectDictLabel = selectDictLabel
app.config.globalProperties.selectDictLabels = selectDictLabels

app.component('DictTag', DictTag)

app
  .use(store)
  .use(router)
  .use(ElementPlus, { locale: zhLocale })
  .mount('#app')

DictData.install()

// 设置生产模式提示为false
app.config.productionTip = false
